package com.seres.math;

import com.seres.data.Index;
import com.seres.data.IndexImpact;

public class RiskCalculator {
	public IndexEthicalStatus calcNewRiskStatus(Index risk, IndexEthicalStatus old, IndexImpact choiceImpact){
//		if(old.getIndex() != Index.RISK){
//			throw new IllegalArgumentException("old ethical status does not have a risk index");
//		}
//		if(choiceImpact.getIndex() != Index.RISK){
//			throw new IllegalArgumentException("choice impact does not have a risk index");
//		}
		if(!old.getIndex().getName().equals("Risk")){
			throw new IllegalArgumentException("old ethical status does not have a risk index");
		}
		if(!choiceImpact.getIndex().equals(risk)){
			throw new IllegalArgumentException("choice impact does not have a risk index");
		}
		float newValue = old.getValue() + choiceImpact.getValue();
		System.out.println("*** RiskCalculator ***");
		System.out.println("old.getValue(): " + old.getValue());
		System.out.println("choiceImpact.getValue(): " + choiceImpact.getValue());
		
//		if(newValue < Index.RISK.getResetStatusValue()){
//			newValue = Index.RISK.getResetStatusValue();
//		}
//		else if(newValue < Index.RISK.getMinimumStatusValue()){
//			newValue = Index.RISK.getMinimumStatusValue();
//		}
		if(newValue < risk.getResetStatusValue()){
			newValue = risk.getResetStatusValue();
		}
		else if(newValue < risk.getMinimumStatusValue()){
			newValue = risk.getMinimumStatusValue();
		}
		System.out.println("newValue: " + newValue);
		System.out.println("*** RiskCalculator ***");
		return new IndexEthicalStatus(newValue, risk);
	}
}
